import { ElLoading } from "element-plus";

let loadingInstance = null;

const showLoading = (text = "加载中...") => {
  loadingInstance = ElLoading.service({
    lock: true,
    text,
    background: "rgba(0, 0, 0, 0.7)",
  });
};

const closeLoading = () => {
  if (loadingInstance) {
    loadingInstance.close();
    loadingInstance = null;
  }
};

export { showLoading, closeLoading };
